# -*- encoding:utf-8 -*-
# !/usr/bin/env python
'''
    python-0820-05.py
    ======================
    @descript: 
    @copyright:nnz
    @author:dln
    @date: 2021/8/22 20:35
    @version:v1.0
'''
import time

'''
喝茶的过程
烧水 10s
洗茶杯： 3个 每个2s
'''
import threading
class Shaoshui(threading.Thread):
    def __init__(self,p_name,p_time):
        threading.Thread.__init__(self)
        self.__name=p_name
        self.__time=p_time
        pass
    def run(self):
        print('线程{}开始'.format(threading.currentThread().getName()))
        for element in range(self.__time):
            print('线程{}烧水水中，第{}秒。'.format(threading.currentThread().getName(), element + 1))
            time.sleep(1)
            pass
        print('线程{}结束'.format(threading.currentThread().getName()))
        pass
class Beizi(threading.Thread):
    def __init__(self,p_name,p_num,p_time):
        super().__init__(name=p_name)
        self.__num=p_num
        self.__time=p_time
        pass
    def run(self):
        print('线程{}开始'.format(threading.currentThread().getName()))
        for element in range(self.__num):
            print('线程{}开始洗第{}个杯子'.format(threading.currentThread().getName(), element + 1))
            time.sleep(self.__time)
            print('线程{}结束洗第{}个杯子'.format(threading.currentThread().getName(), element + 1))
            pass
        print('线程{}结束'.format(threading.currentThread().getName()))
        pass
if __name__=='__main__':
    print('线程{}开始'.format(threading.currentThread().getName()))
    v_object01=Shaoshui('烧水',10)
    v_object02=Beizi('洗茶杯',3,3)
    v_object01.start()
    v_object02.start()
    v_object01.join()
    v_object02.join()
    print('喝茶')
    print('线程{}结束'.format(threading.currentThread().getName()))
    pass








